package gob.pe.mtc.licencias.DAO;

import gob.pe.mtc.licencias.beans.Cliente;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class ClienteDAOImpl extends HibernateDaoSupport implements ClienteDAO {
	
	private static final Logger logger = Logger.getLogger(ClienteDAOImpl.class);
	
	public ClienteDAOImpl (SessionFactory sessionFactory){
		setSessionFactory(sessionFactory);
	}
	public ClienteDAOImpl(){}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Cliente> listaClientes() {
		logger.debug("trae lista de clientes");
		return getHibernateTemplate().find("from Cliente");
	}

	@Override
	public Cliente obtenerCliente(int cliente) {
		return (Cliente)getHibernateTemplate().find("from Cliente cli where cli.codCliente=? ",new Long(cliente)).get(0);
	}

}
